package com.sean.ClassLoader;

import java.lang.reflect.InvocationTargetException;

public class Main {

    public static void main(String[] args) {
        System.out.println(Main.class.getClassLoader().toString());
        Thread.currentThread().setContextClassLoader(new CustomerClassLoader());

        try {
            CustomerClassLoader customerClassLoader = ((CustomerClassLoader) Thread.currentThread()
                    .getContextClassLoader());
            Class test = customerClassLoader.findClass("com.sean.ClassLoader.Test");
            Object b = test.newInstance();
            test.getMethod("display").invoke(b);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
       /* Class<?> a = new CustomerClassLoader().findClass("com.sean.ClassLoader.Test");

        try {
            Object b = a.newInstance();
            a.getMethod("display").invoke(b);
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }*/
    }
}
